package com.example.intelligentattendancesystem.controller;

import com.example.intelligentattendancesystem.pojo.Absence;
import com.example.intelligentattendancesystem.pojo.User;
import com.example.intelligentattendancesystem.service.AbsenceService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author
 * @version 1.0
 * @className AbsenceController
 * @since 1.0
 */
@RestController
@RequestMapping("smartAttendance/absence")
public class AbsenceController {


    @Autowired
    AbsenceService absenceService;
    /**
     * 获取所有缺勤记录
     * @return  缺勤记录列表
     */
    @RequestMapping("/getAllAbsence")

    public List<Absence> getAllAbsence(){
        List<Absence> allAbsenceService = absenceService.getAllAbsenceService();
        return allAbsenceService;
    }

    /**
     * 新加缺勤记录(该接口被废弃，添加在task里面)
     * @param userId 用户id
     * @param startTime 时刻表格的开始时间
     * @param endTime   时刻表格的结束时间
     * @param currentTime   当前时间
     * @return
     */
    @RequestMapping("/addAbsence")
    public boolean addAbsence(int userId,String startTime,String endTime,String currentTime){
        boolean b = absenceService.addAbsenceService(userId, startTime, endTime, currentTime);
        return b;
    }

    /**
     * 获取用户的缺勤记录
     * @param userId 用户id
     * @return
     */
    @RequestMapping("/getAbsence")
    public List<Absence> getAbsence(int userId){
        List<Absence> absenceService1 = absenceService.getAbsenceService(userId);
        return absenceService1;
    }
    /**
     * 获取有缺勤记录的用户
     * @return
     */
    @RequestMapping("/getAbsUsers")
    public List<User> getAbsUsers(){
        List<User> absenceService1 = absenceService.getAbsUsers();
        return absenceService1;
    }
}
